from lib2to3.pgen2 import driver
from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver import Keys


driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
driver.maximize_window()

ele = driver.find_element("id", "kw")
# 在搜索框输入我要吃肉肉肉
ele.send_keys("我要吃肉肉肉")
sleep(1)
# 删除最后一个肉字
ele.send_keys(Keys.BACK_SPACE)
sleep(1)
# 在最后再次输入一个空格
ele.send_keys(Keys.SPACE)
sleep(1)
# 将搜索框内的内容全选Ctrl+a
ele.send_keys(Keys.CONTROL, "a")
sleep(1)
# 全选后进行剪切 Ctrl+x
ele.send_keys(Keys.CONTROL, "x")
sleep(1)
# 剪切后进行粘贴Ctrl+v
ele.send_keys(Keys.CONTROL, "v")
sleep(1)
# 按回车键代替确定搜索
ele.send_keys(Keys.ENTER)
sleep(1)
# 模拟tab制表符键
ele.send_keys(Keys.TAB)
sleep(1)










sleep(3)
driver.quit()